package com.nkym.wypan.controller;

import com.nkym.wypan.model.context.chat.RoomMemberContext;
import com.nkym.wypan.model.req.chat.RoomMemberReq;
import com.nkym.wypan.model.resp.socket.ChatUserInfoVO;
import com.nkym.wypan.response.BaseResponse;
import com.nkym.wypan.service.RoomMemberService;
import com.nkym.wypan.utils.UserContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName GroupMemberController
 * @Author nkym
 * @Date 2023-11-11 11:20
 * @Version 1.0
 */
@RestController
@RequestMapping("/room/member")
@Api(tags = "chat room member api")
public class RoomMemberController {

    @Resource
    RoomMemberService roomMemberService;

    @GetMapping
    @ApiOperation(
            value = "获取群成员列表"
    )
    public BaseResponse<List<ChatUserInfoVO>> getMember(@Valid
                                                            RoomMemberReq req) {
        Long roomId = req.getRoomId();
        Long userId = UserContextHolder.getId();
        RoomMemberContext roomMemberContext = new RoomMemberContext();
        roomMemberContext.setUserId(userId);
        roomMemberContext.setRoomId(roomId);

        List<ChatUserInfoVO> res = roomMemberService.getMember(roomMemberContext);
        return BaseResponse.ok(res);

    }

}
